#ifndef BASE_MEMORY_H
#define BASE_MEMORY_H

#include "base_core.h"


//-----------------------------------------------------------------------------
// Memory allocation
//-----------------------------------------------------------------------------


/**
 * \brief Allocate memory.
 * \param size Number of bytes to allocate
 * \return Pointer to allocated momory.
 * \warning On failure, the function calls exit(EXIT_FAILURE)
 */
void* mem_allocate(size_t size);

/**
 * \brief Free memory.
 * \param ptr Pointer to free
 */
void mem_free(void *ptr);

/**
 * \brief Duplicate a string using mem_allocate().
 * \param str C String to duplicate
 * \return Duplicated string.
 */
char* mem_strdup(const char *str);

/**
 * \brief Get current number of pending allocations.
 * \return Number of memory allocations.
 */
int mem_get_nb_allocations(void);

#endif
